#include "scene.h"
#include "render/scene3D.h"
#include "render/render_system.h"
#include <opengl/opengl_shader.h>
#include "entity/point_entity.h"
#include "entity/line_entity.h"
#include "entity/triangle_entity.h"
#include "entity/sprite.h"
#include "entity/cube.h"
#include "entity/camera.h"

namespace engine
{
    RenderSystem *RenderSystem::renderSystem = nullptr;

    RenderSystem::RenderSystem()
    {
    }

    void RenderSystem::init()
    {
        _scene = std::make_shared<Scene3D>(); // 3D场景
        // _scene = std::make_shared<Scene3D>(getShader("word3d")); // 3D场景
    }

    void RenderSystem::render(double time)
    {
        _scene->render(time);
    }

    void RenderSystem::processInput(GLFWwindow *window)
    {
        _scene->processInput(window);
    }

    Shader *RenderSystem::loadShader(std::string name, const char *vShaderFile, const char *fShaderFile, const char *gShaderFile)
    {
        shaders[name] = new Shader(vShaderFile, fShaderFile);
        return shaders[name];
    }

    bool RenderSystem::removeShader(std::string name)
    {
        shaders.erase(name);
        return true;
    }

    Shader *RenderSystem::getShader(std::string name)
    {
        return shaders[name];
    }

    Texture2D *RenderSystem::loadTexture(std::string name, const char *textureFile, bool alpha)
    {
        textures[name] = new ColorTexture2D(textureFile);
        return textures[name];
    }

    Texture2D *RenderSystem::getTexture(std::string name)
    {
        return textures[name];
    }

    bool RenderSystem::removeTexture(std::string name)
    {
        textures.erase(name);
        return true;
    }

}